
//数据序列化类统一管理
import 'package:framelib/net/base_entity_factory.dart';
import 'package:module_business/module_comm/model/user_entity.dart';
import 'country_entity.dart';
import 'credentials_entity.dart';

class CommEntityFactory with BaseEntityFactory{
  static final CommEntityFactory _singleton = CommEntityFactory._internal();

  static CommEntityFactory get instance => CommEntityFactory();


  factory CommEntityFactory() {
    return _singleton;
  }

  CommEntityFactory._internal(){
    //做一些操作
  }

   T generateOBJ<T>(json) {
    if(json==null)return null;
    if (1 == 0) {
      return null;
    } else if (T.toString() == "String") {
      return json as T;
    }
    else if (T.toString() == "UserEntity") {
      return UserEntity.fromJson(json) as T;
    }else if (T.toString() == "CredentialsEntity") {
      return CredentialsEntity.fromJson(json) as T;
    }else if (T.toString() == "CountryEntity") {
      return CountryEntity.fromJson(json) as T;
    }
    else {
      return null;
    }
  }
}
